<?php
/**
 * Created by PhpStorm.
 * User: wuxiaojie
 * Date: 2018/6/9
 * Time: 15:48
 *
 * 购物车
 */

if (!defined('IN_ANWSION')) {
    die;
}

class main extends AWS_CONTROLLER
{

    public function get_access_rule()
    {
        $rule_action['rule_type'] = "white"; //'black'黑名单,黑名单中的检查  'white'白名单,白名单以外的检查

        if ($this->user_info['permission']['visit_explore'] AND $this->user_info['permission']['visit_site']) {
            $rule_action['actions'][] = 'index';
        }

        return $rule_action;
    }

    public function setup()
    {
        if (is_mobile() AND !$_GET['ignore_ua_check']) {
            switch ($_GET['app']) {
                default:
                    HTTP::redirect('/m/');
                    break;
            }
        }
    }


    public function index_action()
    {
        TPL::assign('seo', array('title'=>'购物车'));


        $carts = $this->model('cart')->get_cart_list_by_uid($this->user_id);
        $cart_goods = array();
        if($carts['cart_content']['gids']){
           $cart_goods = $this->model('goods')->get_goods_info_by_gids($carts['cart_content']['gids']);
        }

        $like_list = $this->model('goods')->fetch_page('goods','', 'goods_id DESC', $_GET['page'], $this->per_page);


        TPL::assign('carts', $carts);
        TPL::assign('cart_goods', $cart_goods);

        TPL::assign('like_list', $like_list);
        TPL::output('aomas/customer_service/index');

    }


}